package com.xcx.robot.mirai.factory.facade;

import com.xcx.robot.api.NetEaseMusicApi;
import com.xcx.robot.mirai.factory.BaseFacade;
import com.xcx.robot.mirai.key.KeyWord;
import com.xcx.robot.mirai.util.KeyUtils;
import lombok.extern.slf4j.Slf4j;
import net.mamoe.mirai.contact.Contact;
import net.mamoe.mirai.message.data.MusicKind;
import net.mamoe.mirai.message.data.MusicShare;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author: 邢晨旭
 * @Date: 2021/5/26 16:18
 * @Description:
 */
@Service
@Slf4j
public class MusicFacade implements BaseFacade {
    public KeyWord keyWord = KeyWord.MUSIC;

    @Resource
    NetEaseMusicApi netEaseMusicApi;

    @Override
    public void execute(Contact sender, Contact receiver, String content) {
        MusicShare musicCard = netEaseMusicApi.getMusicCard(KeyUtils.getKeyByWord(content, 2));
        if(musicCard!=null){
            receiver.sendMessage(musicCard);
        }
        else{
            receiver.sendMessage("没有查到哦");
        }
    }

    @Override
    public KeyWord keyWord() {
        return keyWord;
    }
}
